﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Microhard.Permission.Interface;
using Micrhard.FMCG.Server.Models;
using Micrhard.FMCG.Server.Interface;
using Microsoft.Practices.Unity;
using Microhard.WebUI.Models;
using Telerik.Web.Mvc;
using Microhard.Permission.MVCFilter;
using Microhard.Core.DBUtility;
using Microhard.WeixinMP.Unities;
using Microhard.Permission.MVCFilter.MVCFilter;

namespace Microhard.FMCG.WebUI.Areas.Orders.Controllers
{
    public class CustomerController : MicroHardBaseController<CustomerModel>
    {
        private ICustomer _resp = null;
        [Dependency]
        public ICustomer Customer
        {
            set
            {
                base._repository = value;
                _resp = value;
            }
            get
            {
                return _resp;
            }
        }

        [MVCFilterAtrForLogon(Order = 0)]
        [MVCFilterAtrForResourcePermission(OperationKeyName = "Index", Order = 1)]
        [MVCFilterAtrForDataPermission(OnExecutingFilterDataType = "Index", Order = 2)]
        public ActionResult CustomerSelect(AttributeOfWindow aowModel, ScopeResult scope)
        {
            int totalCount;
            _resp.scope = scope;
            var rtn = _resp.Query(new CustomerModel(), 0, 10, out totalCount);
            aowModel.Data = new GridModel()
            {
                Data = rtn,
                Total = totalCount
            };
            return View(aowModel);
        }
    }
}
